import React from 'react';
import RouterView from './router/RouterView';
import { useEffect } from 'react';
import { useinitLayoutChangeFun, useDispatchTheme } from '/@/store/hooks/theme';
//国际化
import '/@/locales';
import { AliveScope } from 'react-activation';
import { AuthContext } from './components/AuthContext';
function App() {
  //初始化布局
  const initLayoutChangeFun = useinitLayoutChangeFun();
  const dispatch = useDispatchTheme();
  let Load = JSON.parse(localStorage.getItem('themeConfig') as any);
  useEffect(() => {
    // 获取缓存中的布局配置
    if (Load) {
      dispatch.stateSetThemeConfig('themeConfig', Load);
    }
    initLayoutChangeFun;
  }, [dispatch, Load]);

  return (
    <AliveScope>
      <AuthContext.Provider value={{ auth: 'admin' }}>
        <RouterView />
      </AuthContext.Provider>
    </AliveScope>
  );
}

export default App;
